//
//  HJTabBar.swift
//  HJWeiBo
//
//  Created by 黄珏 on 15/10/26.
//  Copyright © 2015年 黄珏. All rights reserved.
//

import UIKit

class HJTabBar: UITabBar {
    
    /// tabBar的数量
    let count : CGFloat = 5
    
    /**f
     重载layoutSubviews
    */
    override func layoutSubviews() {
        super.layoutSubviews()
        /// 获得每个tabBar的宽度
        let width = UIScreen.mainScreen().bounds.width / count
        var index : CGFloat = 0
        for view in subviews{
            if view is UIControl && !(view is UIButton){
                let viewX = width * index
                view.frame = CGRectMake(viewX, 0, width, self.bounds.height)
                index += index == 1 ? 2 : 1
            }
        }
    }
}
